package org.soenea.doitall.domain.command;

import org.dsrg.soenea.domain.MapperException;
import org.dsrg.soenea.domain.command.CommandError;
import org.dsrg.soenea.domain.command.CommandException;
import org.dsrg.soenea.domain.command.DomainCommand;
import org.dsrg.soenea.domain.helper.Helper;
import org.soenea.doitall.domain.model.group.mapper.GroupInputMapper;
import org.soenea.doitall.domain.model.person.mapper.PersonInputMapper;

public class ViewGroupCommand extends DomainCommand {

	public ViewGroupCommand(Helper helper) {
		super(helper);
	}

	@Override
	public void setUp() throws CommandException {
	}

	@Override
	public void process() throws CommandException {
		try {
			long id = (Long) helper.getAttribute("id");
			helper.setRequestAttribute("group", GroupInputMapper.find(id));
			helper.setRequestAttribute("people", PersonInputMapper.findAllWithoutGroup(id));
		} catch (MapperException e) {
			throw new CommandException(e);
		}
	}

	@Override
	public void tearDown() throws CommandError {
	}

}
